<template>
	<view>
		<uni-nav-bar title="深圳掌上宽带办理" backgroundColor="#26a2ff" color="#fff" shadow="true" statusBar="true" fixed="true"
		 class="up-uni-navbar"></uni-nav-bar>
		<swiper :indicator-dots="true" indicator-color="#fff" indicator-active-color="#ccc" :autoplay="false" :interval="3000"
		 :duration="1000" circular="true" class="swiper">
			<swiper-item>
				<view class="swiper-item">
					<image src="../../static/img/banner/mbanner1.png" mode="" class="swiper-item-image"></image>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">
					<image src="../../static/img/banner/mbanner2-.jpg" mode="" class="swiper-item-image"></image>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">
					<image src="../../static/img/banner/mbanner2.jpg" mode="" class="swiper-item-image"></image>
				</view>
			</swiper-item>
		</swiper>
		<h2 class='h2'>宽带资费</h2>
		<!-- <view class="container"> -->
		<scroll-view id="tab-bar" class="scroll-h" :scroll-x="true" :show-scrollbar="false" :scroll-into-view="scrollInto">
			<view class="uni-tab-view">
				<view v-for="(tab,index) in tabBars" :key="tab.id" class="uni-tab-item" :id="tab.id" :data-current="index" @click="ontabtap">
					<text class="uni-tab-item-title" :class="tabIndex==index ? 'uni-tab-item-title-active' : ''">{{tab.name}}</text>
				</view>
			</view>
		</scroll-view>
		<view class="line-h"></view>
		<swiper :current="tabIndex" class="swiper-box" style="flex: 1;" :duration="300" @change="ontabchange">
			<swiper-item class="swiper-item">
				<!-- <CzcItem></CzcItem> -->
				<Goods></Goods>
			</swiper-item>
			<swiper-item class="swiper-item">
				<XqItem></XqItem>
			</swiper-item>
			<swiper-item class="swiper-item">
				<SyItem></SyItem>
			</swiper-item>
		</swiper>
		<!-- </view> -->
	</view>
</template>

<script>
	import CzcItem from './czcItem'
	import XqItem from './xqItem'
	import SyItem from './syItem'
	import Goods from './goods'

	export default {
		data() {
			return {
				nbTitle: '标题',
				titleIcon: '/static/logo.png',
				titleIconRadius: '20px',
				subtitleText: 'subtitleText',
				nbLoading: false,
				nbFrontColor: '#000000',
				nbBackgroundColor: '#ffffff',
				href: "https://uniapp.dcloud.io/component/README?id=uniui",
				tabIndex: 0,
				tabBars: [{
					name: '城中村优惠套餐',
					id: 'guanzhu'
				}, {
					name: '小区优惠套餐',
					id: 'tuijian'
				}, {
					name: '商业宽带优惠套餐',
					id: 'tiyu'
				}],
				scrollInto: "",
			}
		},
		components: {
			CzcItem,
			XqItem,
			SyItem,
			Goods
		},
		methods: {
			ontabtap(e) {
				// console.log(e)
				let index = e.target.dataset.current || e.currentTarget.dataset.current
				this.tabIndex = index
				this.scrollInto = this.tabBars[index].id
			},
			ontabchange(e) {
				let index = e.detail.current || e.target.current
				this.tabIndex = index
				this.scrollInto = this.tabBars[index].id
			},
		}
	}
</script>

<style scoped lang="scss">
	.swiper {
		height: 750/640*270rpx;

		.swiper-item {
			display: flex;
			justify-content: center;

			.swiper-item-image {
				display: block;
				width: 750rpx;
				height: 750/640*270rpx;
			}
		}
	}

	.container {
		padding: 40rpx;
		font-size: 28rpx;
		line-height: 48rpx;
	}

	.h2 {
		height: 80rpx;
		line-height: 80rpx;
		font-size: 40rpx;
		text-align: center;
	}

	.scroll-h {
		width: 750rpx;
		height: 80rpx;
		flex-direction: row;
		/* #ifndef APP-PLUS */
		white-space: nowrap;

		/* #endif */
		.uni-tab-view {
			display: flex;
		}

		.uni-tab-item {
			flex: 1;
			text-align: center;
			/* #ifndef APP-PLUS */
			display: inline-block;
			/* #endif */
			flex-wrap: nowrap;
			// padding-left: 34rpx;
			// padding-right: 34rpx;
		}

		.uni-tab-item-title {
			color: #555;
			font-size: 25rpx;
			height: 80rpx;
			line-height: 80rpx;
			flex-wrap: nowrap;
			/* #ifndef APP-PLUS */
			white-space: nowrap;
			/* #endif */
		}

		.uni-tab-item-title-active {
			color: #007AFF;
		}
	}

	.line-h {
		height: 1rpx;
		background-color: #cccccc;
	}

	.swiper-box {
		height: 715rpx;

		.swiper-item {
			overflow: auto;
		}
	}
</style>
